const path = require('path')
const FixWebpack5EntryPlugin = require('./fix-webpack5-entry-plugin')

module.exports = {
  configureWebpack: {
    // 修复 webpack 5 entry 配置问题
    entry: {
      'app': path.resolve(__dirname, 'src/main.js')
    },
    plugins: [
      new FixWebpack5EntryPlugin()
    ]
  },
  chainWebpack: config => {
    // 确保 entry 是一个对象而不是函数
    if (typeof config.entry !== 'object') {
      config.entry = {
        'app': path.resolve(__dirname, 'src/main.js')
      }
    }
    
    // 添加自定义插件
    config.plugin('fix-webpack5-entry').use(FixWebpack5EntryPlugin)
  }
}